import { http } from "@/utils/http";
import { baseUrlApi, filerEmptyVal } from "./utils";

/** 活动列表 */
export const getActList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/activity/page"), {
    params: filerEmptyVal(params)
  });
};

/** 新增活动 */
export const addAct = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/activity/add"), {
    data
  });
};

/** 编辑活动 */
export const upAct = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/activity/update"), {
    data
  });
};

/** 活动详情 */
export const getActDetail = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/activity/detail"), {
    params
  });
};

/** 提交问卷 */
export const addActAsk = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/login/activity/ask/add"), {
    data
  });
};

/** 问卷列表 */
export const getAskList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/activity/ask/page"), {
    params: filerEmptyVal(params)
  });
};

/** 删除问卷 */
export const delAsk = (id?: object) => {
  return http.request<any>("post", baseUrlApi(`/activity/ask/delete?id=${id}`));
};

/** 删除活动 */
export const delAct = (id?: object) => {
  return http.request<any>("post", baseUrlApi(`/activity/delete?id=${id}`));
};

/** 投稿列表 */
export const getSubList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/submit/page"), {
    params: filerEmptyVal(params)
  });
};

/** 新增投稿 */
export const addSub = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/login/submit/add"), {
    data
  });
};

/** 删除投稿 */
export const delSub = (id?: object) => {
  return http.request<any>("post", baseUrlApi(`/submit/delete?id=${id}`));
};
